import { BaseEntity } from 'src/common/entitys/base';
import { PageEntity } from 'src/modules/page/entities';
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm';

@Entity({ name: 'sys_menu', comment: '系统菜单表' })
export class MenuEntity extends BaseEntity {
  @PrimaryColumn({ name: 'menu_id', type: 'char', comment: '菜单id', length: 36 })
  menuId: string;

  @Column({ name: 'parent_id', type: 'char', comment: '父菜单id', length: 36, nullable: true })
  parentId: string | null;

  @Column({ name: 'menu_name', type: 'varchar', length: 255, comment: '菜单名称' })
  menuName: string;

  @Column({ name: 'order_num', type: 'int', comment: '菜单排序', default: 0 })
  orderNum: number;

  @Column({ name: 'icon', type: 'varchar', comment: '菜单图标', nullable: true })
  icon: string;

  @Column({ name: 'page_id', type: 'varchar', length: 36, comment: '页面id -- 与页面资源关联', nullable: true })
  pageId: string | null;

  @ManyToOne(() => PageEntity)
  @JoinColumn({ name: 'page_id' })
  page: PageEntity;
}
